package com.qf.mvc2202.controller;

import com.qf.mvc2202.exhandler.UserException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 演示出现异常
 */

@Controller
@RequestMapping("/ex")
public class ExController {

    @RequestMapping("/test1")
    public String test1(){

        try {
            int a = 1/0;
        } catch (Exception e) {
            System.out.println(e.getMessage());
            // 返回友好的错误页面
            return "/error/error.jsp";
        }

        return "/hello.jsp";
    }



    @RequestMapping("/test2")
    public String test2(){

        if (true) {
            throw new UserException(1000,"用户模块出现问题了");
        }

        return "/hello.jsp";
    }

}
